//
//  AddViewController.m
//  17-HomeWork
//
//  Created by dllo on 16/8/5.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "AddViewController.h"

@interface AddViewController ()
@property (nonatomic, strong)UIImageView *addImage;
@property (nonatomic, strong)UITextField *nameText;
@property (nonatomic, strong)UITextField *iphoneText;
@property (nonatomic, strong)UITextField *text;
@end

@implementation AddViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"添加联系人";
    self.view.backgroundColor = [UIColor whiteColor];
    [self subViews];
    
}



- (void)subViews {
    _addImage = [[UIImageView alloc] initWithFrame:CGRectMake(70, 80, self.view.bounds.size.width - 140, self.view.bounds.size.width - 140)];
    _addImage.layer.cornerRadius = (self.view.bounds.size.width - 140) / 2;
    _addImage.image = [UIImage imageNamed:@"死神"];
    _addImage.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_addImage];
    _nameText = [[UITextField alloc] initWithFrame:CGRectMake(50, 280, self.view.bounds.size.width - 100, 50)];
    _nameText.layer.borderWidth = 2.0;
    _nameText.placeholder = @"联系人";
    [self.view addSubview:_nameText];
    _iphoneText = [[UITextField alloc] initWithFrame:CGRectMake(50, 330, self.view.bounds.size.width - 100, 50)];
    _iphoneText.placeholder = @"联系方式";
    _iphoneText.layer.borderWidth = 2.0;
    [self.view addSubview:_iphoneText];
    _text = [[UITextField alloc] initWithFrame:CGRectMake(50, 380, self.view.bounds.size.width - 100, 50)];
    _text.placeholder = @"联系地址";
    _text.layer.borderWidth = 2.0;
    [self.view addSubview:_text];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(40, 450, self.view.bounds.size.width - 80, 50);
    [btn setTitle:@"添加" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(clickAdd:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)clickAdd:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(addPersonName:iphone:text:Image:)]) {
        [self.delegate addPersonName:_nameText.text iphone:_iphoneText.text text:_text.text Image:_addImage.image];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
